﻿using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Runtime.InteropServices;
using VMExplorer.Win32;

namespace VMExplorer.MemoryObjects
{
  /// <summary>
  ///  Startup parameters
  /// </summary>
  class ProcessParametersObject : RemoteMemoryObject<Native.RTL_USER_PROCESS_PARAMETERS>
  {
    #region Construction

    private ProcessParametersObject (SafeProcessHandle hProcess, MemoryAddress baseAddress)
      : base(hProcess, baseAddress, RegionUsage.Process)
    {
      Name = "Process Parameters";
    }

    public static IEnumerable<IMemoryObject> Create (SafeProcessHandle hProcess, MemoryAddress baseAddress)
    {
      List<IMemoryObject> memObjects = new List<IMemoryObject> ();
      if (baseAddress.IsValid)
      {
        #region :: ProcessParametersObject ::

        ProcessParametersObject ppo = new ProcessParametersObject (hProcess, baseAddress);
        memObjects.Add (ppo);

        #endregion
        #region :: Environment ::

        memObjects.Add (new EnvironmentBlockObject (hProcess, ppo.Inner.Environment));

        #endregion
      }
      return memObjects;
    }

    #endregion
  }
}
